package com.ynu.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ynu.bean.entity.Advertise;
import com.ynu.bean.entity.Carasel;
import com.ynu.bean.vo.AdvertiseVO;
import com.ynu.bean.vo.CaraselVO;
import com.ynu.converter.AdvertiseConverter;
import com.ynu.converter.CaraselConverter;
import com.ynu.mapper.AdvertiseMapper;
import com.ynu.mapper.CaraselMapper;
import com.ynu.service.AdvertiseService;
import com.ynu.service.CaraselService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *  模块名称：
 *  模块类型：
 *  编码人：迟宽席
 *  创建时间：2023/3/1
 *  联系电话：18388068273
 */
@Service
public class AdvertiselServiceImpl implements AdvertiseService {

    @Resource
    private AdvertiseMapper advertiseMapper;

    @Resource
    private AdvertiseConverter advertiseConverter;

    @Override
    public List<AdvertiseVO> getAdvertise(Integer type, Integer state, Integer amount) {
        //分页：取前amount条
        Page<Advertise> page = PageHelper.startPage(1, amount);
        //查询可用的轮播图
        advertiseMapper.selectAdvertise(type,state);

        List<Advertise> advertiseList = page.getResult();
        //转换
        List<AdvertiseVO> advertiseVOList = advertiseConverter.advertiseList2AdvertiseVOList(advertiseList);

        return advertiseVOList;
    }
}
